package safeCommitter.core.template;

import java.util.Collections;
import java.util.Set;

import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.internal.core.JavaProject;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;

import safeCommitter.model.adpters.ClassEntity;
import safeCommitter.utils.JavaModelUtils;

public class SingleCheckerTemplate extends ASCTemplate implements ISCTemplate {

	private ICompilationUnit unit;

	public void executeTests(final IAction action) {
		super.executeTests(javaProject);
		Activator.getDefault().setCurrentProject(javaProject);
		Set<ClassEntity> clazzEntities = Collections.singleton(JavaModelUtils
				.getClassEntity(unit));
		getTemplate().executeTests(action, javaProject, clazzEntities, null);
	}

	public void setSelection(final ISelection sel, final IAction action) {
		setSelection(sel);

	}

	public void setProject(final IJavaProject project) {
		javaProject = (JavaProject) project;

	}

	public void setUnit(final ICompilationUnit javaElement) {
		this.unit = javaElement;

	}

}
